package kr.saeildadim.androidexam_saeildamil.chapter7;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;

public class DrawBitmapEx extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		DrawView dv = new DrawView(this);
		setContentView(dv);
		
		
	}
}

class DrawView extends View{
	Bitmap bit;
	Canvas offscreen;
	Paint pnt;
	Bitmap backBit;
	
	public DrawView(Context context) {
		super(context);
		bit = BitmapFactory.decodeResource(getResources(), R.drawable.harubang); 
		backBit = Bitmap.createBitmap(300,200, Config.ARGB_8888);
		offscreen = new Canvas(backBit);
		offscreen.drawColor(Color.GREEN);
		pnt = new Paint();
		pnt.setColor(Color.RED);
	}
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		/*canvas.drawBitmap(bit, 10, 10, null);
		canvas.drawBitmap(bit, null, new Rect(120,10,170,85), null);
		canvas.drawBitmap(bit, new Rect(30,30,70,80), new Rect(180,10,180+80,101+00), null);
		canvas.drawBitmap(bit, null, new Rect(10,200,380,400),null);*/
		canvas.drawColor(Color.LTGRAY);
		for(int x=0;x<300;x+=10){
			offscreen.drawLine(x, 0, 300-x, 200, pnt);
		}
		canvas.drawBitmap(backBit, 10, 10, null);
	}
}